<template>
    <div class="order" style="height:500px;width:auto;overflow:scroll">
         <h2>我的订单</h2>
        <Col :xs="48" :sm="24" :md="24" :lg="24">
            <divider></divider>
            <Table max-height="400" border stripe :columns="coloumnsorder" :data="orderdata"></Table>
        </Col>
    </div>
</template>

<script>
export default {
    name: 'order',
    data() {
        return {
            index: 999,
            orderdata: [
            ],
            coloumnsorder: [
                {
                    title: '订单号',
                    width: 250,
                    key: 'orderid',
                },
                {
                    title: '交换对象',
                    width: 250,
                    key: 'exchangeobj',
                },
                {
                    title: '交换书籍（我的）',
                    width: 200,
                    key: 'mybook',
                },
                {
                    title: '交换书籍（对方）',
                    width: 200,
                    key: 'objbook',
                },
                {
                    title: '交换时间',
                    width: 300,
                    key: 'time',
                },
                {
                    title: '交换状态',
                    width: 200,
                    key: 'state',
                },
            ],
        }
    },
    created() {
        fetch('http://localhost:5000/myorder', {
            method: 'post',
            body: JSON.stringify({
                username: localStorage.getItem('userName'),
            }),
            headers: { 'Content-Type': 'application/json' },
        }).then(
            res => res.json()
        ).then(
            res => {
                let conInfo = res.data
                let length = res.length
                for (let i = 0; i < length; i++) {
                    this.orderdata.push(conInfo[i])
                }
            }
        )
    },
}
</script>

<style scoped>

</style>
